import java.io.*;
import java.util.Scanner;
import java.io.File;



public class Ceshi {
    public static void main(String[]args)throws Exception {
        String s0 = new String();
        String s7 = new String();
        String s2;
        String s3 = "";
        String s4 = new String();
        String s5 = new String();
        String s6 = new String();
        int a = 0;
        int i = 6;
        int count = 0;
        // 第1步：使用File类找到一个文件;创建一个写出文件
        File read = new File("D:\\桌面\\Java上机实验\\12.10文本处理" + File.separator + "Wenben1.txt");
        File write = new File("D:\\桌面\\Java上机实验\\12.10文本处理"+File.separator+"Wenben2.txt");
        //第二步：给BufferReader做实例化
        BufferedReader Read = new BufferedReader(new FileReader(read));
        BufferedWriter Write = new BufferedWriter(new FileWriter(write));
        //第三步：读取值并且存到s1中
        String s1 = Read.readLine();
        while (true) {
            s2 = s1.substring(a, i + 1);
            if (i % 2 == 0) {
                s3 = s2 + '，';
            }
            if (i % 2 != 0) {
                s4 = s2 + '。';
                s5 = s3 + s4;
                System.out.println(s5);
                s0=s0+s5+"\n";

            }
            a = i + 1;
            i += 7;
            if (i > 238) {
                break;
            }
        }

        s6 = s1.substring(238, s1.length());
        s7=s0+"\n"+s6;
        Write.write(s7);

        // 第4步：缓冲，关闭输出流
        Write.flush();
        Write.close();
        System.out.println(s6);

        //把字符串转换成字符，存入字符数组中
        char A[];
        A = s1.toCharArray();

        System.out.println("请输入一个需要检索次数的字：");
//         Scanner 输入语句用法
        Scanner scanner = new Scanner(System.in);
        String WB = scanner.next();
        char wb = WB.charAt(0);
        for (int I = 0; I < s1.length(); I++) {
            if (A[I] == wb) {
                count += 1;
            }

        }
        System.out.println("该字出现的次数为：" + count);
    }
}
